package theOrbalEra.client.OrbalArts.render;

import java.util.Random;

import org.lwjgl.opengl.GL11;

import theOrbalEra.client.ClientProxy;
import theOrbalEra.common.util.DefultValue;

import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.util.AxisAlignedBB;

public class OrbalRenderFireBolt extends OrbalRenderOrbalArt {
	
Random ran=new Random();
	@Override
	public void doRender(Entity entity, double d0, double d1, double d2,
			float f, float f1) {
		renderFireShoot(entity,d0,d1,d2,f,f1);

	}

	private void renderFireShoot(Entity entity, double d0, double d1,double d2, float f, float f1) {
		this.tick++;
		if(tick==360){
			tick=0;
		}
		 GL11.glEnable(GL11.GL_BLEND);
         GL11.glDisable(GL11.GL_LIGHTING);
         GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
         GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F);
		     GL11.glPushMatrix();
		     this.loadTexture(DefultValue.Texture_FireBolt);
		    
             GL11.glTranslatef((float)d0, (float)d1, (float)d2);
             GL11.glRotatef(tick, 1.5F, 1.5F, 1.5F);
		     GL11.glCallList(ClientProxy.sphereID);
		     GL11.glPopMatrix();
		     
		     GL11.glPushMatrix();
		     GL11.glTranslatef((float)d0, (float)d1, (float)d2);
		  //   this.renderAABBwithUV(AxisAlignedBB.getBoundingBox(-1.0D, -0.5D, -1.0D, 1.0D, 0.5D, 1.0D));
		     GL11.glPopMatrix();
		     GL11.glDisable(GL11.GL_BLEND);
		     GL11.glEnable(GL11.GL_LIGHTING);

		     
		   
		
	}

	private void renderAABBwithUV(AxisAlignedBB boundingBox) {
		Tessellator tessellator=new Tessellator();
		tessellator.startDrawingQuads();
		tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 0.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 1.0D);
	    
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 0.0D, 1.0D);
	    
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 0.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 0.0D, 0.0D);
	   
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 0.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 0.0D, 1.0D);
	   
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 0.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 0.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 0.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.minX-ran.nextFloat()*boundingBox.minX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 0.0D, 0.0D);
	    
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 0.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.minZ-ran.nextFloat()*boundingBox.minZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.maxY-ran.nextFloat()*boundingBox.maxY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 1.0D);
	    tessellator.addVertexWithUV(boundingBox.maxX-ran.nextFloat()*boundingBox.maxX, boundingBox.minY-ran.nextFloat()*boundingBox.minY, boundingBox.maxZ-ran.nextFloat()*boundingBox.maxZ, 1.0D, 0.0D);
		
	    tessellator.draw();
		
	}

}
